#!/usr/bin/env python
# Copyright 2021 Chuwei Chen chenchuw@bu.edu

import re
import os
import string

path = '.'

files = os.listdir(path)
strip_files =[]
for i in files:
    strip_files.append(i.strip("!#$%&'()*+,-./:;<=>?@[]^_`{|}~"))

symbol=[]
digit=[]
letter_digit=[]

for i in files:
    if re.match(r'^[0-9]',i):
        digit.append(i)
    elif (re.match(r'^[\W,_]',i)):
        symbol.append(i)
    else:
        letter_digit.append(i)

for j in symbol:
    if re.match(r'^[\w]',j.strip("!#$%&'()*+,-./:;<=>?@[]^_`{|}~")):
        letter_digit.append(j)
        symbol.remove(j)
for j in symbol:
    if re.match(r'^[\w]',j.strip("!#$%&'()*+,-./:;<=>?@[]^_`{|}~")):
        letter_digit.append(j)
        symbol.remove(j)
for j in symbol:
    if re.match(r'^[\w]',j.strip("!#$%&'()*+,-./:;<=>?@[]^_`{|}~")):
        letter_digit.append(j)
        symbol.remove(j)
for j in symbol:
    if re.match(r'^[\w]',j.strip("!#$%&'()*+,-./:;<=>?@[]^_`{|}~")):
        letter_digit.append(j)
        symbol.remove(j)

def first_ascii(elem):
    if elem == '$':
        return 256
    return ord(elem[0])

def complex(elem):
    strip_elem = elem.strip("!#$%&'()*+,-./:;<=>?@[]^_`{|}~")

    return ord(strip_elem[0])

# sorted_letter_digit = sorted(letter_digit, key = str.swapcase)
sorted_symbol = sorted(symbol, key = first_ascii)
sorted_digit = sorted(digit, key = first_ascii)
sorted_letter_digit = sorted(letter_digit, key = complex)

final_list = sorted_symbol + sorted_digit + sorted_letter_digit
for i in final_list:
    print(i)